/**
 * Alibaba.com.cn Inc.
 * Copyright (c) 2004-2021 All Rights Reserved.
 */
package com.hiv.common.helper;

import com.hiv.mapper.HospitalMapper;
import com.hiv.mapper.SamplingBoxMapper;
import com.hiv.mapper.domain.Hospital;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * @author zhanghong
 * @version AccountHelper.java, v 0.1 2022/11/14 14:04 下午 AccountHelper Exp $$
 */
@Component
public class AccountHelper {
    @Autowired
    private HospitalMapper hospitalMapper;
    @Autowired
    private SamplingBoxMapper samplingBoxMapper;

    /**
     * 质控中心下的所有医院id集合
     * @param qualityControlCenterId
     * @return
     */
    public List<Long> qualityControlCenterRelationHospitalIdList(Long qualityControlCenterId) {
        List<Hospital> hospitals = hospitalMapper.listByParentId(qualityControlCenterId);
        return hospitals.stream().map(Hospital::getId).collect(Collectors.toList());
    }

    /**
     * 与检验所有关的医院集合
     * @return
     */
    public List<Long> inspectionRelationHospitalIdList(Long inspectionId) {
        Set<Long> hospitalIdList = samplingBoxMapper.queryByInspectionId(inspectionId);
        return hospitalIdList.stream().collect(Collectors.toList());
    }
}
